import React, { Component } from 'react'
import { Table } from 'antd'

export default class Tables extends Component {
    state={}
    componentWillMount() {
        const data = [
            {
                id:'0',
                userName:'jack',
                sex:'1',
                state:'1',
                interest:'1',
                birthday:'2000-01-01',
                address:'哈尔滨秋林',
                time:'09:00'
            },
            {
                id:'1',
                userName:'jack',
                sex:'2',
                state:'5',
                interest:'1',
                birthday:'2000-01-01',
                address:'哈尔滨秋林',
                time:'09:00'
            },
            {
                id:'2',
                userName:'jack',
                sex:'1',
                state:'3',
                interest:'1',
                birthday:'2000-01-01',
                address:'哈尔滨秋林',
                time:'09:00'
            },
            {
                id:'3',
                userName:'jack',
                sex:'1',
                state:'3',
                interest:'1',
                birthday:'2000-01-01',
                address:'哈尔滨秋林',
                time:'09:00'
            }
        ]
        data.map((value,index) => {
            value.key = index
        })
        this.setState({
            dataSource: data
        })
      
    }
    render() {
        const columns = [
            {
              title:'id',
              dataIndex:'id'  
            },
            {
                title:'用户名',
                dataIndex:'userName'  
              }
              ,
            {
                title:'性别',
                dataIndex:'sex' ,
                render(sex) {
                    return sex == 1 ? "男" : "女"
                } 
              }
              ,
            {
                title:'状态',
                dataIndex:'state',
                render(state ) {
                    let config = {
                        "1":"咸鱼一条",
                        "2":"鲤鱼打挺",
                        "3":"风花雪月",
                        "4":"雪中送炭",
                        "5":"干就完了"
                    }
                    return config[state]
                }  
              }
              ,
            {
                title:'爱好',
                dataIndex:'interest',
                render(interest ) {
                    let config = {
                        "1":"打球",
                        "2":"游泳",
                        "3":"健身",
                        "4":"路铁",
                        "5":"干"
                    }
                    return config[interest]
                }   
              }
              ,
            {
                title:'生日',
                dataIndex:'birthday'  
              }
              ,
            {
                title:'地址',
                dataIndex:'address'  
              }
              ,
            {
                title:'早起时间',
                dataIndex:'time'  
              }
        ]
        return (
            <div>
                <Table
                style={{textAlign:"center"}}
                 columns={columns}
                 dataSource={this.state.dataSource}
                 bordered
                 >
               

                </Table>
            </div>
        )
    }
}
